﻿using DotNetDetour;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using WPFLauncher.Model.Component;

namespace KFX.DotNetDetour.Main
{
    internal class other : IMethodHook
    {
        [HookMethod("WPFLauncher.Manager.Login")]
        private bool e()
        {
            Socket.send("LoginSuccess");
            return false;
        }
        [HookMethod("WPFLauncher.Manager.Configuration.auz", null, null)]
        private static bool get_PlayCG()
        {
            Socket.send("get_PlayCG");
            return false;
        }
        [HookMethod("System.Diagnostics.Process", null, null)]
        public static Process[] GetProcesses()
        {
            Process[] processes_Original = GetProcesses_Original();
            List<Process> list = new List<Process>();
            for (int i = processes_Original.Length; i >= 0; i--)
            {
                bool flag = isSystemProcess(processes_Original[i].ProcessName);
                bool flag2 = flag;
                if (flag2)
                {
                    list.Add(processes_Original[i]);
                }
            }
            return list.ToArray();
        }
        public static bool isSystemProcess(string name)
        {
            string[] array = new string[]
            {
                "dllhost",
                "IAStorDataMgrSvc",
                "fontdrvhost",
                "WmiPrvSE",
                "svchost",
                "crss",
                "SecurityHealthService",
                "spoolsv",
                "dwm",
                "ctfmon",
                "conhost"
            };
            foreach (string value in array)
            {
                bool flag = name.Equals(value);
                bool flag2 = flag;
                if (flag2)
                {
                    return true;
                }
            }
            return false;
        }
        [OriginalMethod]
        public static Process[] GetProcesses_Original()
        {
            return null;
        }
        [HookMethod("WPFLauncher.Network.yx", null, null)]
        public void a(ushort flo, Action<byte[]> flp)
        {
            try
            {
                this.a_Original(flo, flp);
                Socket.send("Network.xu.a" + flo.ToString(), flp.Method.ToString() + " " + flp.Target.ToString());
            }
            catch (Exception)
            {
            }
        }
        [OriginalMethod]
        public void a_Original(ushort fkk, Action<byte[]> fkl)
        {
        }
    }
}
